package de.mindshareprojects.datawarehouse.shared;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class CampaignList {
	
	private ArrayList<Campaign> Items = new ArrayList<Campaign>();

/**
 * 
 * @param campaignList ArrayList<Campaign>
 */
	public CampaignList(ArrayList<Campaign> campaignList){
		this.Items = campaignList;
	}
	
	public void setItems(ArrayList<Campaign> items) {
		Items = items;
	}

	public ArrayList<Campaign> getItems() {
		return Items;
	}
	
	/**
	 * sorts CampaignList 
	 */
	public void sort(final String criterion){
		Collections.sort(this.Items, new Comparator<Campaign>(){

			@Override
			public int compare(Campaign c1, Campaign c2) {
				int result = 0;
				if(criterion.equalsIgnoreCase("name")){
					result = c1.getCampaignName().compareToIgnoreCase(c2.getCampaignName());
				}
				else if(criterion.equalsIgnoreCase("key")){
					result = c1.getKey().compareTo(c2.getKey());
				}
				else if(criterion.equalsIgnoreCase("advertiserName")){
					result = c1.getAdvertiserName().compareTo(c2.getAdvertiserName());
				}
				return result;
			}
		});
	}
	
	/**
	 * reverses the order
	 */
	public void reverse(){
		Collections.reverse(this.Items);
	}

	
	public String toString(){
		String output = "";
		
		
		return output;
		
	}
}
